package com.ruoyi.order.service.impl;

import com.ruoyi.order.domain.Order;
import com.ruoyi.order.mapper.OrderMapper;
import com.ruoyi.order.service.IOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class OrderServiceImpl implements IOrderService {

    @Autowired
    private OrderMapper orderMapper;

    @Override
    public Order selectOrderById(String candidateId) {
        return orderMapper.selectOrderById(candidateId);
    }

    @Override
    public List<Order> selectOrderList() {
        return orderMapper.selectOrderList();
    }

    @Override
    public int insertOrder(Order order) {
        if ("已缴费".equals(order.getPayment_status())) {
            order.setPayment_time(LocalDateTime.now());
        }
        return orderMapper.insertOrder(order);
    }

    @Override
    public int updateOrder(Order order) {
        if ("已缴费".equals(order.getPayment_status())) {
            order.setPayment_time(LocalDateTime.now());
        }
        return orderMapper.updateOrder(order);
    }

    @Override
    public int deleteOrderById(String candidateId) {
        return orderMapper.deleteOrderById(candidateId);
    }
}
